package com.itheima.jobs;


import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.service.OrderSettingService;
import org.springframework.stereotype.Component;

import java.util.Calendar;
import java.util.Date;

@Component
public class ClearOrderSettingJob {

    @Reference
    private OrderSettingService orderSettingService;

    /**
     * 清理从以本月时间的上年之前所有的预约记录
     */
    public void clearExtraOrderSetting() throws Exception {
        Calendar calendar = Calendar.getInstance();
        //获取上一年的一号
        calendar.set(Calendar.MONTH,-12);
        calendar.set(Calendar.DAY_OF_MONTH,1);
        Date date = calendar.getTime();
        orderSettingService.clearExtraOrderSetting(date);
    }
}
